<template>
	<view class="page">
		<view class="p12 bg-white">
			<u-search placeholder="搜索关键词" @search="initData" v-model="keyword"></u-search>
		</view>
		<view class="page-content p12" style="background: #f5f5f5;">


			<view class="">

				<view class="u-flex " style="flex-wrap: wrap;">
					<view @click="toInfo(item)" style="width: 50%;min-width: 50%;" class="mb10 p6"
						v-for="(item,index) in dataList" :key="index">

						<view  class=" bg-white brs5 ">
							<view class="">

								<view class="u-flex u-f-justify">
									<image :src="item.picUrl" style="height:340rpx;" mode="heightFix"></image>
								</view>
								<view class="u-flex u-f-jsb fz14 mt10 p12" style="color: #19291C;">
									<span class="u-line-1">{{item.name}}</span>
									<span style="color: #FE3307;" class="fz16 u-font-bold">￥{{item.price}}</span>
								</view>
							</view>
						</view>
					</view>
				</view>
				<view class="">

					<u-loadmore :status="loadStatus" v-if="dataList.length>0" />
				</view>
				<view class="order-none u-flex u-f-justify fz16 c9 p50" v-if="dataList.length<=0">
					暂无数据！
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getPlatform
	} from '@/config/util.js'
	export default {
		data() {
			return {
				background: {
					background: '#fff'
				},
				loadStatus: 'more',
				scrollHeight: 300,
				dataList: [],
				keyword: '',
				page: 1,
			}
		},
		onLoad() {

			this.initData()
		},
		onShow() {},
		// 页面下拉到底部触发
		onReachBottom() {
			if (this.loadStatus == 'more') {
				this.getData()
			}
		},
		methods: {

			toInfo(item) {
				uni.navigateTo({
					url: '/pages/product/info?id=' + item.id
				})
			},
			initData() {
				this.page = 1
				this.dataList = []
				this.getData()

			},
			toEdit(id) {
				uni.navigateTo({
					url: '/pages/order/confirm?order_id=' + id
				})
			},
			getData() {
				console.log(this.currentType, 111111111)
				let post = {
					pageNo: this.page,
					pageSize: 10,
					categoryIds:'14,15,16,19,21,38,22,26,27,28,47',
					keyword: this.keyword,
				}
				this.$api.productSearch(post, res => {
					if (res.code == 200) {
						let _list = res.data.list
						this.dataList = [...this.dataList, ..._list]
						// 判断所有数据是否请求完毕
						if (res.data.total > this.dataList.length) {
							this.page++
							this.loadStatus = 'more'
						} else {
							this.loadStatus = 'noMore'
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.module-btn {
		.btn {
			background: rgba(137, 195, 255, 0.3);
			color: rgb(26, 109, 255);
			height: 54upx;
			display: flex;
			align-items: center;
			justify-content: center;
			flex: 1;
			font-size: 24rpx;
			padding: 0 30rpx;
			border-radius: 50rpx;
			text-align: center;
			margin-left: 20rpx;
		}
	}

	.ic-video {
		position: absolute;
		top: 30rpx;
		right: 30rpx;
		font-size: 60rpx;
		z-index: 2;
	}

	.theme-list {
		display: flex;
		text-align: center;

		.item {
			padding: 0 30rpx 30rpx;

			&.on {
				border-bottom: 1px solid #70B52C;

				.item-img {
					border: 1px solid #70B52C;
				}
			}
		}

		.item-img {
			overflow: hidden;
			background: #F4F4F4;
		}

		.item-title {
			color: #19291C;
		}
	}
</style>